function findParentWithClass(element: any, className: any) {
  let currentElement = element;

  // Loop until we find the class or reach the top of the DOM tree
  while (currentElement && currentElement !== document) {
    if (
      currentElement.classList &&
      currentElement.classList.contains(className)
    ) {
      return currentElement; // Found the element with the specified class
    }
    currentElement = currentElement.parentNode; // Move to the parent node
  }

  return null; // Class not found in the DOM tree
}

export const screenFull = (el: any, chartRef: any, height: any) => {
  const foundElement = findParentWithClass(el.target, "screen-full-box");
  const foundElementFull = findParentWithClass(el.target, "screenFull");
  if (foundElementFull) {
    foundElement.classList.remove("screenFull");
    chartRef._dom.style.height = height;
  } else if (foundElement && !foundElementFull) {
    foundElement.classList.add("screenFull");
    chartRef._dom.style.height = window.innerHeight - 120 + "px";
  }
  setTimeout(() => {
    chartRef.resize();
  }, 6);
};